class Date:
    def __init__(self, year, month, day):
        self.year = year
        self.month = month
        self.day = day


# 不调用 __init__() 方法来创建这个Date实例
d = Date.__new__(Date)  # 这样就没有d.year的属性

data = {'year': 2012, 'month': 8, 'day': 29}

for key, value in data.items():
    setattr(d, key, value)
print(d.year)

# 反序列对象，需要绕过__init__的方法创建对象
from time import localtime


class Date1:
    def __init__(self, year, month, day):
        self.year = year
        self.month = month
        self.day = day

    @classmethod
    def today(cls):
        d = cls.__new__(cls)
        t = localtime()
        d.year = t.tm_year
        d.month = t.tm_mon
        d.day = t.tm_mday
        return d

m = Date1.today().year
